Skip to content

Conversation

@cosmastech
Copy link
Contributor

In Laravel, if you attempt to update a Model but have made no changes to its data, it will not write to the database. See Eloquent@save().

While the chances are vanishingly small that this would happen enough times to significantly affect benchmarks, I wanted to remove noise from the benchmarks.

@cosmastech cosmastech marked this pull request as draft May 27, 2025 17:18
@cosmastech cosmastech marked this pull request as ready for review May 29, 2025 13:48
while ($queries--) {
$row = World::query()->find(self::randomInt());
$row->randomNumber = self::randomInt();
$row->randomNumber = ($randomInt = self::randomInt()) !== $row->randomNumber ? $randomInt : $randomInt + 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If $randomInt is 10000 this would fail, as 10001 is invalid.
Other frameworks generate a new random number instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! was not aware of that requirement. I've updated the method accordingly.

@msmith-techempower msmith-techempower merged commit 08e68e4 into TechEmpower:master May 30, 2025
3 checks passed
@cosmastech cosmastech deleted the patch-1 branch May 30, 2025 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants